class Student:
# 定义一个初始化方法，用于创建一个学生对象
    def __init__(self, stu_id, name, age):
        # 将传入的学号赋值给对象的stu_id属性
        self.stu_id = stu_id
        # 将传入的姓名赋值给对象的name属性
        self.name = name
        # 将传入的年龄赋值给对象的age属性
        self.age = age


class StudentManager:
    def __init__(self):
        self.students = []

    def add_student(self, student):
        self.students.append(student)

    def find_student_by_id(self, stu_id):
        for student in self.students:
            if student.stu_id == stu_id:
                return student
        return None


def main():
    manager = StudentManager()
    while True:
        print("\n学生信息管理系统")
        print("1. 输入学生信息")
        print("2. 查询学生信息")
        print("3. 退出系统")
        choice = input("请选择操作：")

        if choice == '1':
            stu_id = input("请输入学号：")
            name = input("请输入姓名：")
            while True:
                age = input("请输入年龄：")
                try:
                    age = int(age)
                    break
                except ValueError:
                    print("年龄必须为数字，请重新输入！")

            new_student = Student(stu_id, name, age)
            manager.add_student(new_student)
            print("学生信息添加成功！")

        elif choice == '2':
            stu_id = input("请输入要查询的学生学号：")
            student = manager.find_student_by_id(stu_id)
            if student:
                print("查询结果：")
                print(f"学号：{student.stu_id}")
                print(f"姓名：{student.name}")
                print(f"年龄：{student.age}")
            else:
                print("未找到该学生信息")

        elif choice == '3':
            print("感谢使用，再见！")
            break

        else:
            print("无效的选项，请重新输入！")


if __name__ == "__main__":
    main()